import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;
import javax.swing.Popup;

public class menuBar extends JMenuBar {
	
	public menuBar(final JFrame index) {
			super();
	
        final JMenu file;
		JMenu edit, view, help, submenu;
        JMenuItem newFile, open, save, exit, undo, redo, copy, cut, paste, about;
        JRadioButtonMenuItem rbMenuItem;
        JCheckBoxMenuItem cbMenuItem;
        final JFileChooser fc = new JFileChooser();

        //Create the menu bar.
        //menu = new JMenuBar();

        //Build the first menu.
        file = new JMenu("File");
        file.setMnemonic(KeyEvent.VK_F);
        file.getAccessibleContext().setAccessibleDescription(
                "The only menu in this program that has menu items");
        this.add(file);
        
        edit = new JMenu("Edit");
        edit.setMnemonic(KeyEvent.VK_E);
        edit.getAccessibleContext().setAccessibleDescription(
                "The only menu in this program that has menu items");
        this.add(edit);
        
        view = new JMenu("View");
        view.setMnemonic(KeyEvent.VK_V);
        view.getAccessibleContext().setAccessibleDescription(
                "The only menu in this program that has menu items");
        this.add(view);
        
        help = new JMenu("Help");
        help.setMnemonic(KeyEvent.VK_H);
        help.getAccessibleContext().setAccessibleDescription(
                "The only menu in this program that has menu items");
        this.add(help);

        /*File Menu Operations*/ {
        
        //a group of JMenuItems
        newFile = new JMenuItem("New",
                                 KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        newFile.setMnemonic(KeyEvent.VK_N);
        newFile.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_N, ActionEvent.CTRL_MASK));
        newFile.getAccessibleContext().setAccessibleDescription(
                "This doesn't really do anything");
        newFile.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent evt) {
				test.contentPane.add(test.addPalette());
				
			}});
        file.add(newFile);
        
        open = new JMenuItem("Open File...",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        open.setMnemonic(KeyEvent.VK_O);
        open.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        open.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        open.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent evt) {
        		fc.showOpenDialog(file);
        	}
        });
        file.add(open);
        
        save = new JMenuItem("Save",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        save.setMnemonic(KeyEvent.VK_S);
        save.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_S, ActionEvent.CTRL_MASK));
        save.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        save.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent evt) {
        		fc.showSaveDialog(file);
        	}
        });
        file.add(save);
        
        exit = new JMenuItem("Exit",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        exit.setMnemonic(KeyEvent.VK_X);
        //exit.setAccelerator(KeyStroke.getKeyStroke(
        		//KeyEvent.VK_O, ActionEvent.CTRL_MASK));
        exit.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        exit.addActionListener(new ActionListener(){
        	public void actionPerformed(ActionEvent evt)
        	{
        		System.exit(0);
        	}
        });
        file.add(exit);
        
        }
        
        /*Edit Menu Operations*/ {
        
        undo = new JMenuItem("Undo",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        undo.setMnemonic(KeyEvent.VK_U);
        undo.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
        undo.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        undo.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}});
        edit.add(undo);
        
        redo = new JMenuItem("Redo",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        redo.setMnemonic(KeyEvent.VK_R);
        redo.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_Y, ActionEvent.CTRL_MASK));
        redo.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        redo.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}});
        edit.add(redo);
        
        cut = new JMenuItem("Cut",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        cut.setMnemonic(KeyEvent.VK_T);
        cut.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_X, ActionEvent.CTRL_MASK));
        cut.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        cut.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}});
        edit.add(cut);
        
        copy = new JMenuItem("Copy",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        copy.setMnemonic(KeyEvent.VK_C);
        copy.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_C, ActionEvent.CTRL_MASK));
        copy.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        copy.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}});
        edit.add(copy);
        
        paste = new JMenuItem("Paste",
                KeyEvent.VK_T);
        //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
        paste.setMnemonic(KeyEvent.VK_P);
        paste.setAccelerator(KeyStroke.getKeyStroke(
        		KeyEvent.VK_P, ActionEvent.CTRL_MASK));
        paste.getAccessibleContext().setAccessibleDescription(
        		"This doesn't really do anything");
        paste.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
			}});
        edit.add(paste);
        
        }
        
        /*Help Menu Operations*/ {
        	
        	about = new JMenuItem("About",
                    KeyEvent.VK_T);
            //menuItem.setMnemonic(KeyEvent.VK_T); //used constructor instead
            about.setMnemonic(KeyEvent.VK_A);
            //undo.setAccelerator(KeyStroke.getKeyStroke(
            	//	KeyEvent.VK_Z, ActionEvent.CTRL_MASK));
            about.getAccessibleContext().setAccessibleDescription(
            		"This doesn't really do anything");
            about.addActionListener(new ActionListener(){

				@Override
				public void actionPerformed(ActionEvent e) {
					JOptionPane.showMessageDialog(index, "CSE 2102 Software Engineering Project\nCreated by Alex Fogarty");
					
				}});
            help.add(about);        	
        	
        }
/*
        ImageIcon icon = createImageIcon("images/middle.gif");
        menuItem = new JMenuItem("Both text and icon", icon);
        menuItem.setMnemonic(KeyEvent.VK_B);
        menuItem.addActionListener(this);
        file.add(menuItem);

        menuItem = new JMenuItem(icon);
        menuItem.setMnemonic(KeyEvent.VK_D);
        menuItem.addActionListener(this);
        file.add(menuItem);

        //a group of radio button menu items
        file.addSeparator();
        ButtonGroup group = new ButtonGroup();

        rbMenuItem = new JRadioButtonMenuItem("A radio button menu item");
        rbMenuItem.setSelected(true);
        rbMenuItem.setMnemonic(KeyEvent.VK_R);
        group.add(rbMenuItem);
        rbMenuItem.addActionListener(this);
        file.add(rbMenuItem);

        rbMenuItem = new JRadioButtonMenuItem("Another one");
        rbMenuItem.setMnemonic(KeyEvent.VK_O);
        group.add(rbMenuItem);
        rbMenuItem.addActionListener(this);
        file.add(rbMenuItem);

        //a group of check box menu items
        file.addSeparator();
        cbMenuItem = new JCheckBoxMenuItem("A check box menu item");
        cbMenuItem.setMnemonic(KeyEvent.VK_C);
        cbMenuItem.addItemListener(this);
        file.add(cbMenuItem);

        cbMenuItem = new JCheckBoxMenuItem("Another one");
        cbMenuItem.setMnemonic(KeyEvent.VK_H);
        cbMenuItem.addItemListener(this);
        file.add(cbMenuItem);

        //a submenu
        file.addSeparator();
        submenu = new JMenu("A submenu");
        submenu.setMnemonic(KeyEvent.VK_S);

        menuItem = new JMenuItem("An item in the submenu");
        menuItem.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_2, ActionEvent.ALT_MASK));
        menuItem.addActionListener(this);
        submenu.add(menuItem);

        menuItem = new JMenuItem("Another item");
        menuItem.addActionListener(this);
        submenu.add(menuItem);
        file.add(submenu);
*/
        //Build second menu in the menu bar.

        return;
    }}
